import 'package:flutter/material.dart';

class UserProfile extends StatelessWidget {
  const UserProfile({super.key, required this.userName, required this.userAvatarUrl, required this.userSignature});
  final String userName;
  final String userAvatarUrl;
  final String userSignature;

  Widget _initImage(){
    return userAvatarUrl == "" ?
    const Hero(
        tag: "avatarImg",
        child: CircleAvatar(
          radius: 40,
          backgroundImage: AssetImage("assets/images/Default_head.png"),
        )
    ):
    Hero(
        tag: "avatarImg",
        child: CircleAvatar(
          radius: 40,
          backgroundImage: NetworkImage(userAvatarUrl),
        )
    );
  }

  Widget _initUserSignature(){
    return userSignature == "" ?
    const Text(
      "这个人很懒，什么都没有留下",
      style: TextStyle(
          fontSize: 13,fontWeight: FontWeight.w300,
          color: Colors.white
      ),
    ):
    Text(
      userSignature,
      style: const TextStyle(
          fontSize: 13,fontWeight: FontWeight.w300,
          color: Colors.white
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Padding(
          padding: const EdgeInsets.all(10),
          child: Row(
            children: [
              _initImage(),
              Padding(
                padding: const EdgeInsets.fromLTRB(15, 0, 0, 0),
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text(userName,style: const TextStyle(
                        fontSize: 31,
                        fontWeight: FontWeight.w500,
                        color: Colors.white
                    ),
                    ),
                    const SizedBox(height: 4,),
                    _initUserSignature(),
                  ],
                ),
              )
            ],
          ),
        ),
      ],
    );
  }
}